#ifndef SERVERTCP_H
#define SERVERTCP_H

#include <QTcpServer>
#include <QTcpSocket>
#include <QVector>
#include <QJsonObject>
#include "sql/sqlrequest.h"

class ServerTCP : public QTcpServer
{
    Q_OBJECT
public:
    ServerTCP();
    QTcpSocket *socket, *socketSend;

private:
    QByteArray Data;
    QMap<QString,QString> devices;
    QMap<QString,QString> devicesTimekeeper;
    QMap<QString,QString> devicesParticipants;
    QList<QString> client;
    QMap<int, QTcpSocket*> SClient;
    SqlRequest* sql;
    int deviceSocketTimekeeper = 0;
    int deviceSocketParticipants = 0;

signals:
    void connect_judges(int idDevice);
    void sig_dickconnect(int numSud);
    void perfomance_judges(QJsonObject obj);
    void read_ocenki();
    void connect_timekeeper(int idDevice);
    void connect_participants(int idDevice);
    void start_stop_timer();

public slots:
    void incomingConnection(qintptr socketDescriptor);
    void slotReadyRead();
    void startServer();
    void SendToCLient(QJsonObject obj);
    void slotClientDisconnected();
    void SendToDevice(QJsonObject obj);
//    void SendToTimekeeper(QJsonObject obj);
//    void SendToParticipants(QJsonObject obj);
};

#endif // SERVERTCP_H
